<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Log extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->helper('file');
		$this->load->helper('url');
		
		$this->load->helper('MY_xml');
		$dom = xml_dom(); 
		$book = xml_add_child($dom, 'book'); 
		xml_add_child($book, 'title', 'Hyperion'); 
			

		$author = xml_add_child($book, 'author', 'Dan Simmons'); 

		xml_print($dom); 
				$url='C:\\xampp\\htdocs\\logtest\\';
				$data = 'Some file data';

		if ( ! write_file('././log/test.txt', xml_print($dom,true)))
		{
			 echo 'Unable to write the file';
		}
		else
		{
			 echo 'File written <br/>';
		}
	}

public function read(){
		$this->load->helper('file');
		$this->load->helper('url');
		$this->load->helper('xml');
		$this->load->helper('MY_xml');
		$filename = $fname.'.xml';  
		//$dom=$domDocument->loadXML(read_file('././log/test.txt'));
           var_dump($dom);
		   //  $xmlfile="./xml/".$filename;  
             $xmlRaw = read_file('././log/test.txt');
  
             $this->load->library('simplexml');  
              $this->simplexml->xml_parse($xmlRaw);
			 $this->simplexml->array_insert(count($this->simplexml->result), 'author', 'radit', 1);  
			 var_dump($this->simplexml->result);                                        
//		$dom = 


}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */